package com.qf;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * description: ServletContextListener - 监听Application作用域的创建，
 *                  Application是在Tomcat启动时创建，而且只会创建一次
 * author: Ken
 * 公众号：Java架构栈
 */
@WebListener
public class ApplicationListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("Tomcat启动了.....");
        //Tomcat服务启动后，就需要执行的代码
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        System.out.println("Tomcat销毁.....");
    }
}
